<?php
/**
 * @filesource:					NodeAction.class.php
 * @desc:						操作节点模块模型类
 * 
 * @author:						houyining
 * @copyright:					hou.yining@gmail.com	
 * @date:						2011-04-12
 */

class NodeModel extends Model {
	protected $_validate	=	array(
		array('name','checkNode','节点已经存在',0,'callback'),
		array('name', 'require', '节点名不能为空 ！'),
		array('title', 'require', '节点标题不能为空！'),
		array('sort', 'require', '排序值不能为空！'),
		array('sort', 'number', '排序值必须是数字！'),
		);
	
	protected $_auto = array(
		array('status', 1),
	);
	public function checkNode() {
		$map['name']	 =	 $_POST['name'];
		$map['pid']	=	isset($_POST['pid'])?$_POST['pid']:0;
        $map['status'] = 1;
        if(!empty($_POST['id'])) {
			$map['id']	=	array('neq',$_POST['id']);
        }
		$result	=	$this->where($map)->field('id')->find();
        if($result) {
        	return false;
        }else{
			return true;
		}
	}
}
?>